/* 
 *  Incub - incubate your baby robot
 *  Copyright (C) 2008 Stanislaw Szymczyk
 *  e-mail: sszymczy@gmail.com   www: http://cogville.cog-lab.com
 *
 *  This file is part of Incub.
 *
 *  Incub is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  Incub is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with Incub.  If not, see <http://www.gnu.org/licenses/>.
 * 
 */
 
#ifndef JOINT_CPP_
#define JOINT_CPP_

#include "Joint.h"

using std::string;
using std::vector;

Joint::Joint() {
	this->entity = NULL;
	this->parentEntity = NULL;
}

void Joint::setAnchor(string anchor) {
	sscanf(anchor.c_str(), "%lf %lf %lf", &this->anchor.x, &this->anchor.y, &this->anchor.z);	
}

Vector3D& Joint::getAnchor() {
	return anchor;
}

void Joint::setEntity(Entity *entity) {
	entity->setParentJoint(this);
	this->entity = entity;
}

Entity* Joint::getEntity() {
	return entity;
}

void Joint::setParentEntity(Entity *parentEntity) {
	this->parentEntity = parentEntity;
}

Entity* Joint::getParentEntity() {
	return parentEntity;
}

void Joint::addMotor(Motor* e) {
	motors.push_back(e);
}

vector<Motor*>& Joint::getMotors() {
	return motors;
}

Joint::~Joint() {
	for(vector<Motor*>::iterator motor = motors.begin(); motor != motors.end(); motor++) {
		delete *motor;
	}
	if(this->entity != NULL) {
		delete this->entity;
	}
}

#endif /*JOINT_CPP_*/
